package com.wx.chapter12.customexception_;

/**
 * @Author : 佩萁
 * Description :
 * @Create : 2023/7/9 - 14:41
 */
public class CustomException {
    public static void main(String[] args) {
        int age = 18;
        if (!(age >= 18 && age <= 120)) {
            throw new AgeException("年龄需要在18~20之间");
        }
        System.out.println("你的年龄范围正常");
    }
}

class AgeException extends RuntimeException {
    public AgeException(String message) {
        super(message);
    }
}